package com.food.config;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@ApiModel("自定义全局异常类")
public class FoodException extends RuntimeException {
    private Integer code;

    private String message;

    public FoodException(Integer code) {
        this.code = code;
    }

    public FoodException(String message) {
        super(message);
        this.message = message;
    }

    public FoodException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public FoodException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }


    @Override
    public String toString() {
        return "FoodException{" +
                "code=" + code +
                ", message='" + message + '\'' +
                '}';
    }
}
